package com.gas.gm.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

public abstract class ChannelConfigurator {
	
    static final String ROUTE_SMS_CHANNEL="ROUTESMS";
	static final String TELKOMSEL_CHANNEL="TELKOMSEL";
	
	static Properties properties=new Properties();
	
	static final String TELKOMSEL_HALO="telkomsel.halo";
	static final String TELKOMSEL_HALO_11="telkomsel.halo.11";
	static final String TELKOMSEL_SIMPATI="telkomsel.simpati";
	static final String INDOSAT_MATRIX="indosat.matrix";
	static final String INDOSAT_MATRIX_BRIGHT="indosat.matrix.bright";
	static final String INDOSAT_MENTARI1="indosat.mentari1";
	static final String INDOSAT_MENTARI2="indosat.mentari2";
	static final String INDOSAT_M3="indosat.m3";
	static final String INDOSAT_M3_NEW="indosat.m3.new";
	static final String XL1="xl1";
	static final String XL2="xl2";
	static final String XL3="xl3";
	
	

	public static String fix(String add){
		loadProperties();
		if(isRouteSMS(add))
			return ROUTE_SMS_CHANNEL;
		else
			return TELKOMSEL_CHANNEL;
				
	}
	
	static void loadProperties()
	{
		try {
			properties.load(new FileInputStream(new File(GasFileMode.getPrefixPropPath())));
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	static boolean isRouteSMS(String add){
		boolean routesms=true;
		String num=add.substring(0, 6);
		if(num.contains((CharSequence) properties.get(TELKOMSEL_HALO))||num.contains((CharSequence) properties.get(TELKOMSEL_HALO_11))||num.contains((CharSequence) properties.get(TELKOMSEL_SIMPATI)))
			routesms=false;
		return routesms;
	}
}
